﻿using RayDen.Library.Core.Primitives;


namespace RayDen.Library.Core {
    public class RayInfo : IRay {
        public Vector  Dir, InvDir;
        public Point Org;
        public float MinT, MaxT;

        protected RayInfo(){}

        public RayInfo(Point org, Vector dir, float t0 = 1e-4f, float t1 = 1e4f)
        {
            this.Org = org;
            this.Dir = dir;
            this.MinT = t0;
            this.MaxT = t1;
            InvDir = 1f/dir;
        }
        public RayInfo(ref Point org,ref Vector dir, float t0 = 1e-4f, float t1 = 1e4f)
        {
            this.Org = org;
            this.Dir = dir;
            this.MinT = t0;
            this.MaxT = t1;
            InvDir = 1f / dir;
        }
        public RayInfo(RayInfo vray) {
            this.Org = vray.Org;
            this.Dir = vray.Dir;
            InvDir = 1f / vray.Dir;
            this.MinT = vray.MinT;
            this.MaxT = vray.MaxT;
        }

        #region IRay Members

        public Point Origin
        {
            get { return Org; }
        }
        public Vector InvDirection {
            get { return InvDir; }
        }
        public Vector Direction {
            get { return Dir; }
        }

        public float Min {
            get { return MinT; }
        }

        public float Max {
            get { return MaxT; }
        }

        public Point Point(float distance)
        {
            return Org + Dir*distance;
        }
        public void SetSegment(float min, float max) {
            this.MinT = min;
            this.MaxT = max;
        }



        #endregion
    }
}